from time import *


def bubble(list1):
    for i in range(len(list1) - 1):
        for k in range(len(list1) - 1):
            if list1[k] > list1[k + 1]:
                list1[k], list1[k + 1] = list1[k + 1], list1[k]
    return list1


def readfile(filename):
    file = open(filename)
    list1 = file.readlines()
    return list1


t1 = readfile('m1_sorted.txt')
t2 = readfile('m2_reverse.txt')
t3 = readfile('m3_shuffle.txt')

t_start = time()
bubble(t1)
t_finish = time()
print('m1_sorted.txt', round((t_finish - t_start) * 1000), 'milliseconds')

t_start = time()
bubble(t2)
t_finish = time()
print('m2_reverse.txt', round((t_finish - t_start) * 1000), 'milliseconds')

t_start = time()
bubble(t3)
t_finish = time()
print('m3_shuffle.txt', round((t_finish - t_start) * 1000), 'milliseconds')
